// 测试 concat 、join 、slice 函数

const names = [ '孙悟空' , '猪悟能' , '奔波儿灞' , '灞波儿奔' ];

const loongs = [ '敖广' , '敖钦' , '敖顺' , '熬闰' ];

// Array.prototype.concat( ...items )
const array = names.concat( loongs );
console.log( array === names ); // true
console.log( array === loongs ); // true
console.log( 'names: ' , names.toString() );
console.log( 'loongs: ' , loongs.toString() );
console.log( 'array: ' , array.toString() );

// Array.prototype.join( [separator] )
let str = array.join( '|' );
console.log( str );

let x = array.concat( '诸葛亮' , '刘伯温' , '袁天罡' );
console.log( x.toString() );

// Array.prototype.slice( [begin[, end]] ) 从数组中截取子集并返回新数组
let y = x.slice();
console.log( y.toString() );
console.log( x === y ); // false
y[ 0 ] = '孙大圣' ;
console.log( x.toString() );
console.log( y.toString() );

let z = x.slice( 2 , 5 );
console.log( z.toString() );

// 总结:
// Array.prototype.concat( ...items )
// Array.prototype.join( [ separator ] )
// Array.prototype.slice( [begin[, end]] )